//
//  ThawViewController.m
//  YiBaoStore
//
//  Created by 吕清毅 on 2018/11/25.
//  Copyright © 2018年 小河. All rights reserved.
//

#import "ThawViewController.h"

@interface ThawViewController ()

@end

@implementation ThawViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = HexWithAlpha(0x000000, 0.6);
    [self setMainView];
}

- (void)setMainView
{
    CGFloat padding = (SCREENHEIGHT - 220)/2;
    UIView *backView = [UIView new];
    backView.frame = CGRectMake(55, padding, SCREENWIDTH-110, 220);
    backView.backgroundColor = TotalWhite;
    backView.layer.cornerRadius = 5;
    [self.view addSubview:backView];
    
    UILabel *titleLab = [UILabel new];
    titleLab.frame = CGRectMake(0, 17, backView.width, 14);
    titleLab.textColor = titleColor;
    titleLab.font = FontSemiboldSize(14);
    titleLab.text = self.isSuccess?@"成功解冻订单！":@"余额不足";
    titleLab.textAlignment = NSTextAlignmentCenter;
    [backView addSubview:titleLab];
    
    UIImageView *close = [UIImageView new];
    close.frame = CGRectMake(backView.width-31, 15, 16, 16);
    close.image = [UIImage imageNamed:@"anClose"];
    [backView addSubview:close];
    
    UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    closeBtn.frame = CGRectMake(close.left-5, 10, 26, 26);
    [closeBtn addTarget:self action:@selector(close) forControlEvents:UIControlEventTouchUpInside];
    [backView addSubview:closeBtn];
    
    UIImageView *iv = [UIImageView new];
    float ivPadd = (backView.width-100)/2;
    iv.frame = CGRectMake(ivPadd, titleLab.bottom+15, 100, 100);
    iv.image = [UIImage imageNamed:self.isSuccess?@"freezeSuccess":@"freezeFail"];
    [backView addSubview:iv];
    
    UILabel *desLab = [UILabel new];
    desLab.frame = CGRectMake(15, iv.bottom+15, backView.width-30, 40);
    desLab.textColor = UIColorFromHex(0xA9A9A9);
    desLab.font = FontWithSize(14);
    desLab.textAlignment = NSTextAlignmentCenter;
    desLab.numberOfLines = 0;
    desLab.text = [NSString stringWithFormat:@"%@",self.msg];
    [backView addSubview:desLab];
}

- (void)close
{
    if (self.isSuccess)
    {
        self.backData(@"success");
        [self.view removeFromSuperview];
    }
    else
    {
        [self.view removeFromSuperview];
    }
}

@end
